  var req;
  var datadisplay;    
  function retrieveURL(url, textId) {
    alert('url: ' + url + '; textId: ' + textId);
	if (window.XMLHttpRequest) { // For IE7+, Firefox, Chrome, Opera 8.0+, Safari
	      req = new XMLHttpRequest();
	      req.onreadystatechange = processStateChange;
	      try {
	        req.open("GET", url, true);
	      } catch (e) {
	    	  alert('Browser: IE7+ or Firefox or Chrome or Opera 8.0+ or Safari' );
	          alert(e);
	      }
	      req.send(null);
	 }
	else {
		// Internet Explorer Browsers
		try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			alert('First catch! Msxml2.XMLHTTP' );
			try{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Second catch! Your browser outdated!");
				return false;
			}
		}
		if (req) {
			alert('calling processstatechange....');
	        req.onreadystatechange = processStateChange;
	        req.open("GET", url, true);
	        req.send();
		}
	}
    datadisplay = textId;
  }
  
  function processStateChange() {
    if (req.readyState == 4) { // Complete
      if (req.status == 200) { // OK response
      //alert(req.responseText);
        //document.getElementById("urlContent").innerHTML = req.responseText;
        //alert(req.responseText);
        document.getElementById(datadisplay).innerHTML = req.responseText;
        //document.getElementById("endblock").innerHTML = lastblock;
        //document.getElementById("answerblock").innerHTML = '';
      } else {
        alert("Problem: " + req.statusText);
      }
    }
  } 
  
//function processStateChange() {
//	if (req.readyState == 4) { // Complete
//		if (req.status == 200) { // OK response
//			alert(req.responseText);
//	        var responsetext = req.responseText;
//	        alert(responsetext);
//	        document.getElementById("soundPH").innerHTML = '';
//	        if(responsetext.indexOf("The answer is correct") != -1) {
//	        	alert('correct');
//	          	playSound('sound/tada.wav');
//	        }
//	        else if(responsetext.indexOf("Your answer is wrong") != -1) {
//	        	alert('wrong');
//	          	playSound('sound/error.wav');
//	        }
//	        //document.getElementById(datadisplay).innerHTML = req.responseText;
//	        document.getElementById(datadisplay).innerHTML = responsetext;
//		} else {
//	        alert("Problem: " + req.statusText);
//	    }
//	}
//}  
	  
		function playSound(soundfile) {
			document.getElementById("soundPH").innerHTML=document.getElementById("soundPH").innerHTML +
				"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
		}  